package com.xiaoluo.lottery.common.weixin.hb.beans;

import com.xiaoluo.lottery.common.weixin.utils.Configure;
import com.xiaoluo.lottery.common.weixin.utils.RandomStringGenerator;
import com.xiaoluo.lottery.common.weixin.utils.Signature;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;

/**
 * Project : lottery
 * Package : main.java.com.xiaoluo.lottery.common.weixin.pay.enums
 * Created by Willian.
 * Date  : 2016/4/6 14:38.
 */
@Root(name = "xml")
public class RedPackReq {

    @Element(name = "nonce_str")            private String nonce_str;       //随机字符串	   是	5K8264ILTKCH16CQ2502SI8ZNMTM67VS	String(32)	随机字符串，不长于32位
    @Element(name = "sign")                 private String  sign;           //签名	 是	C380BEC2BFD727A4B6845133519F3AD6	String(32)	详见签名生成算法
    @Element(name = "mch_billno")           private String mch_billno;      //商户订单号	   是	10000098201411111234567890	String(28)    商户订单号（每个订单号必须唯一）    组成：mch_id+yyyymmdd+10位一天内不能重复的数字。    接口根据商户订单号支持重入，如出现超时可再调用。
    @Element(name = "mch_id")               private String mch_id;          //商户号	  是	10000098	String(32)	微信支付分配的商户号
    @Element(name = "wxappid")              private String  wxappid;        //公众账号appid	   是	wx8888888888888888	String(32)	微信分配的公众账号ID（企业号corpid即为此appId）。接口传入的所有appid应该为公众号的appid（在mp.weixin.qq.com申请的），不能为APP的appid（在open.weixin.qq.com申请的）。
    @Element(name = "send_name")            private String send_name;       //商户名称	   是	天虹百货	String(32)	红包发送者名称
    @Element(name = "re_openid")            private String re_openid;       //用户openid	 是	oxTWIuGaIt6gTKsQRLau2M0yL16E	String(32)    接受红包的用户            用户在wxappid下的openid
    @Element(name = "total_amount")         private Integer total_amount;	    // 付款金额	是	1000	int	付款金额，单位分
    @Element(name = "total_num")            private Integer total_num;       //红包发放总人数	 是	1	int            红包发放总人数    total_num=1
    @Element(name = "wishing")              private String  wishing;        //红包祝福语	   是	感谢您参加猜灯谜活动，祝您元宵节快乐！	String(128)	红包祝福语
    @Element(name = "client_ip")            private String client_ip;       //Ip地址	 是	192.168.0.1	String(15)	调用接口的机器Ip地址
    @Element(name = "act_name")             private String act_name;        //活动名称	   是	猜灯谜抢红包活动	String(32)	活动名称
    @Element(name = "remark")               private String  remark;         //备注	 是	猜越多得越多，快来抢！	String(256)	备注信息

    public RedPackReq() {
        super();
        init();
    }

    public Integer getTotal_amount() {
        return total_amount;
    }

    public void setTotal_amount(Integer total_amount) {
        this.total_amount = total_amount;
    }

    public String getNonce_str() {
        return nonce_str;
    }

    public void setNonce_str(String nonce_str) {
        this.nonce_str = nonce_str;
    }

    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public String getMch_billno() {
        return mch_billno;
    }

    public void setMch_billno(String mch_billno) {
        this.mch_billno = mch_billno;
    }

    public String getMch_id() {
        return mch_id;
    }

    public void setMch_id(String mch_id) {
        this.mch_id = mch_id;
    }

    public String getWxappid() {
        return wxappid;
    }

    public void setWxappid(String wxappid) {
        this.wxappid = wxappid;
    }

    public String getSend_name() {
        return send_name;
    }

    public void setSend_name(String send_name) {
        this.send_name = send_name;
    }

    public String getRe_openid() {
        return re_openid;
    }

    public void setRe_openid(String re_openid) {
        this.re_openid = re_openid;
    }

    public Integer getTotal_num() {
        return total_num;
    }

    public void setTotal_num(Integer total_num) {
        this.total_num = total_num;
    }

    public String getWishing() {
        return wishing;
    }

    public void setWishing(String wishing) {
        this.wishing = wishing;
    }

    public String getClient_ip() {
        return client_ip;
    }

    public void setClient_ip(String client_ip) {
        this.client_ip = client_ip;
    }

    public String getAct_name() {
        return act_name;
    }

    public void setAct_name(String act_name) {
        this.act_name = act_name;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    /**
     * 初始化系统配置
     */
    public void init(){
        setWxappid(Configure.getAppid());
        setMch_id(Configure.getMchid());
    }

    /**
     * 生成签名信息
     */
    public void builder(){
        setNonce_str(RandomStringGenerator.getRandomStringByLength(32));
        try {
            setSign(Signature.getSign(this));
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}
